package com.cy.sd.controller;

import com.cy.sd.service.ConsumerService;
import com.cy.sd.service.PaymentService;
import jdk.nashorn.internal.ir.annotations.Reference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

@RestController
public class OderController {

    @Autowired
    private ConsumerService consumerService;


    @GetMapping("/consumer/pay/{account}/{money}")
    public String exePay(@PathVariable("account") String account,@PathVariable("money") String money){
        System.out.println(consumerService==null);
        BigDecimal bigDecimal = null;
        try{
            bigDecimal = new BigDecimal(money);
        }catch (Exception e){
            e.printStackTrace();
            return "金额不合法";
        }
        return  consumerService.doPay(account,bigDecimal);
    }
}
